﻿using UnityEngine;
using System.Collections;

public class SparkBehaviour : MonoBehaviour {
    private Transform _cachedTrans;
    public Transform cachedTransform
    {
        get
        {
            if (_cachedTrans==null)
            {
                _cachedTrans = transform;
            }
            return _cachedTrans;
        }
    }

    private GameObject _cachedGameObject;
    public GameObject cachedGameObject
    {
        get
        {
            if (_cachedGameObject == null)
            {
                _cachedGameObject = gameObject;
            }
            return _cachedGameObject;
        }
    }

    private Rigidbody2D _cachedRigidBody2D;
    public Rigidbody2D cachedRigidBody2D
    {
        get
        {
            if (_cachedRigidBody2D == null)
            {
                _cachedRigidBody2D = rigidbody2D;
            }
            return _cachedRigidBody2D;
        }
    }

    private AnimationBroadcaster _animationBroadcaster;
    public AnimationBroadcaster animationBroadcaster
    {
        get
        {
            if (_animationBroadcaster == null)
            {
                _animationBroadcaster = GetComponent<AnimationBroadcaster>();
            }
            return _animationBroadcaster;
        }
    }

    public virtual void DestroyMe()
    {
        Destroy(this);
    }

    public virtual void DestroyObject()
    {
        Destroy(cachedGameObject);
    }
}
